<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    
    <h:head>
        <title>#{names.title}</title>
    </h:head>
    
    <h:body rendered="#{!auth.loggedIn}">
        <ui:include src="login.xhtml" />
    </h:body>
    
    <h:body rendered="#{auth.loggedIn}">
        <h:outputStylesheet library="css" name="style.css"  />
        <h:panelGroup layout="block" class="wrapper">
            <p:panel id="admin_panel" header="#{names.title}" style="margin-bottom:10px;">       
                <ui:include src="header.xhtml" /> 
                <p:panel id="new_user_panel" header="#{names.intUserCreatePanelName}" style="margin-bottom:10px;" styleClass="small">
                    <h:form id="new_user">
                       <h:panelGrid columns="3">
                           <p:outputLabel for="int_name" value="#{names.intUserAttributeUsername}" />
                           <p:inputText id="int_name" value="#{intuser.username}" required="true" requiredMessage="#{names.intUserAttributeUsernameMsg}"/>  
                           <p:message for="int_name" />
                           <p:outputLabel for="int_pass" value="#{names.intUserAttributePassword}" />
                           <p:password id="int_pass" value="#{intuser.password}" match="int_pass_confirm" required="true" requiredMessage="#{names.intUserAttributePasswordMsg}" feedback="true"/>
                           <p:message for="int_pass" />
                           <p:outputLabel for="int_pass_confirm" value="#{names.intUserAttributePassword}" />
                           <p:password id="int_pass_confirm" value="#{intuser.password}" required="true" requiredMessage="#{names.intUserAttributePasswordMsg}" feedback="true"/>                        
                           <p:outputLabel  value="" />                               
                           <p:commandButton id="submit" icon="ui-icon-plus" value="#{names.buttonCreate}" ajax="false" actionListener="#{intusers.add(intuser)}"/>
                       </h:panelGrid>
                   </h:form>                        
                </p:panel>

                <p:panel id="all_users_panel" header="#{names.allIntUserPanelName}" style="margin-bottom:10px;" styleClass="small">
                    <h:form id="edit_user">
                        <p:dataTable id="all_users" var="u" value="#{intusers.intUsers}" rows="15"
                                     emptyMessage="#{names.noEntries}">                                 
                            <p:column sortBy="#{u.username}" headerText="#{names.intUserAttributeUsername}">  
                                <h:outputText value="#{u.username}" />  
                           </p:column>   
                            <p:column style="width:100px;">  
                                <p:commandButton id="viewButton" icon="ui-icon-pencil" value="#{names.buttonEdit}" action="#{intusers.gotoEdit}">
                                    <f:param name="edit" value="#{u.id}"/>
                                </p:commandButton>                                         
                           </p:column>                             
                       </p:dataTable>
                    </h:form>
               </p:panel>
                
            </p:panel>
        </h:panelGroup>
    </h:body>
</html>
